package com.railway.switchs.enums;


import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName EnumOperatorType枚举类
 * @Author 魏梓晟
 * @Version 1.0
 **/
public enum EnumOperatorType {

    OPERATOR_ADD("0","新增"),
    OPERATOR_EDIT("1","修改"),
    OPERATOR_DELETE("2","删除"),
    OPERATOR_ON("3","启用"),
    OPERATOR_OFF("4","禁用"),
    PUBLISH_UP("5","发布"),
    PUBLISH_DOWN("6","撤下"),
    AUTHORIZE("7","授权"),
    TO_AUDIT("8","提交审核"),
    AUDIT_ERROR("9","审核不合格"),
    AUDIT_SUCCESS("A","审核合格");

    private String code;

    private String name;

    private EnumOperatorType(String code, String name){
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private static Map<String, EnumOperatorType> pool = new HashMap<>();

    static {
        for (EnumOperatorType each : EnumOperatorType.values()) {
            pool.put(each.getCode(), each);
        }
    }

    public static EnumOperatorType get(String code) {
        return pool.get(code);
    }

    public static Map<String, String> getAllEnums() {
        Map<String, String> m = new HashMap<String, String>();
        for (EnumOperatorType e : EnumOperatorType.values()) {
            m.put(e.getCode(), e.getName());
        }
        return m;
    }

    public static String getName(String code){
        EnumOperatorType enumOperatorType = pool.get(code);
        if (enumOperatorType == null) {
            return "";
        }
        return enumOperatorType.getName();
    }
}
